package com.xci.sys.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.xci.core.domain.BaseEntity;
import com.xci.core.internal.Const;
import com.xci.core.internal.Sys;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 系统参数
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "系统参数")
public class SysParam extends BaseEntity {
    /**
     * 参数主键
     */
    @ExcelIgnore @Excel(name = "参数主键")
    @ApiModelProperty(value = "参数主键", position = 1)
    private String id;

    /**
     * 参数类型
     */
    @NotNull(message = "请指定参数类型")
    @ExcelIgnore
    @ApiModelProperty(value = "参数类型", position = 6)
    private Integer category;

    /**
     * 参数类型名称
     */
    @Excel(name = "参数类型")
    @ApiModelProperty(hidden = true)
    private String categoryText;

    /**
     * 参数名称
     */
    @NotBlank(message = "参数名称不能为空")
    @Length(max = 100, message = "参数名称不能超过{max}个字符")
    @Excel(name = "参数名称", width = 30d)
    @ApiModelProperty(value = "参数名称", required = true, position = 2)
    private String name;

    /**
     * 参数编码
     */
    @NotBlank(message = "参数编码不能为空")
    @Length(max = 100, message = "参数编码不能超过{max}个字符")
    @Excel(name = "参数编码", width = 30d)
    @ApiModelProperty(value = "参数编码", required = true, position = 4)
    private String code;

    /**
     * 参数值
     */
    @Excel(name = "参数值", width = 40d)
    @ApiModelProperty(value = "参数值", position = 5)
    private String value;

    /**
     * 备注
     */
    @Length(max = 500, message = "备注不能超过{max}个字符")
    @Excel(name = "备注", width = 40d)
    @ApiModelProperty(value = "备注", position = 100)
    private String remark;

    public String getCategoryText() {
        return Sys.me().getDicNameByValue("sys.param.category",category.toString(),Const.EMPTY);
    }
}